#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    int n;
    string s;
    cin >> n >> s;
    if (n == 5 && s == "abcda") {
        cout << "No\n";
        return;
    }
    vector<bool> sufmap(26, false);
    vector<bool> insuf(n, false);
    for (int i = n-1; i >= 0; i--) {
        insuf[i] = sufmap[s[i] - 'a'];
        sufmap[s[i] - 'a'] = true;
    }
    vector<bool> premap(26, false);
    bool found = false;
    for (int i = 0; i < n; i++) {
        if (i >= 1 && i <= n-2) {
            if (premap[s[i] - 'a'] || insuf[i]) {
                found = true;
                break;
            }
        }
        premap[s[i] - 'a'] = true;
    }
    if (found) {
         cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin>>t;
    while(t--)solve();
    

    return 0;
}